﻿Imports Servicios
Imports Negocio

Public Class PanelPrincipal

    Private Sub PanelPrincipal_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        LoadProjects()

    End Sub

    Private Sub LoadProjects()
        dgvProyectos.DataSource = GesProyectos.Consultar(Nothing, Nothing, Nothing, Nothing)
    End Sub

    Private Sub LoadTasks(proyecto As Proyecto)
        dgvTareas.DataSource = GesTareas.Consultar(proyecto)
    End Sub

    Private Sub LoadActivities(tarea As Tarea)
        dgvActividades.DataSource = GesActividades.Consultar(tarea)
    End Sub

    Private Sub dgvProyectos_Click(sender As System.Object, e As System.EventArgs) Handles dgvProyectos.Click
        If dgvProyectos.Rows.Count > 0 AndAlso TypeOf dgvProyectos.CurrentRow.DataBoundItem Is Proyecto Then
            Dim Proy As Proyecto = DirectCast(dgvProyectos.CurrentRow.DataBoundItem, Proyecto)
            LoadTasks(Proy)
        End If
    End Sub

    Private Sub dgvTareas_Click(sender As System.Object, e As System.EventArgs) Handles dgvTareas.Click
        If dgvTareas.Rows.Count > 0 AndAlso TypeOf dgvTareas.CurrentRow.DataBoundItem Is Tarea Then
            Dim Tar As Tarea = DirectCast(dgvTareas.CurrentRow.DataBoundItem, Tarea)
            LoadActivities(Tar)
        End If
    End Sub

End Class